<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>Insert title here</title>
</head>
<script type="text/javascript">
$(function(){
	
	$('#dg').datagrid({    
	    url:'ShowJianPrice_showJianPrice',
	    rownumbers:true,
	    pagination:true,
	    pageSize:10,
	    pageList:[10,15,20],
	    columns:[[  
            {field:'checkbox',title:'ck',width:100,checkbox:true},
	        {field:'tpid',title:'站点编号',width:100},    
	        {field:'disid1',title:'起/始站',width:100},    
	        {field:'disid2',title:'始/起站',width:100,align:'right'},
	        {field:'tprice',title:'价格比例',width:100},
	        {field:'fkgc',title:'首公斤费用',width:100},
	        {field:'subkilogramme',title:'超出的每公斤费用',width:100},
	        {field:'mtm',title:'体积转质量率',width:100},
	        {field:'sta',title:'价格申请状态',width:100},
	    ]],
	    toolbar: [{
			iconCls: 'icon-edit',
			text:'申请变换价格',
			handler: function(){
				var a=$('#dg').datagrid('getSelections');
				if(a.length==1){
				$('#win').window('open');
				$('#tb1').textbox('setValue',a[0].tpid);
				$('#tb2').textbox('setValue',a[0].tprice);
				$('#tb3').textbox('setValue',a[0].fkgc);
				$('#tb4').textbox('setValue',a[0].subkilogramme);
				$('#tb5').textbox('setValue',a[0].mtm);
				}else{
					$.messager.alert('我的消息','请选择一行修改并提交','info');
				}
				
			}
		},'-',{
			iconCls: 'icon-add',
			text:'添加',
			handler: function(){
				$('#win1').window('open');
				$('#cc').combobox('clear');
				$('#cc1').combobox('clear');

			}
		}]

	
	});  
	$('#btn1').bind('click', function(){    
		var tpid=$('#tb1').textbox('getValue');
		var tprice=$('#tb2').textbox('getValue');
		var fkgc=$('#tb3').textbox('getValue');
		var subkilogramme=$('#tb4').textbox('getValue');
		var mtm=$('#tb5').textbox('getValue');   
		$.ajax({
			url:'UpdatePrice_updatePrice',
			type:'post',
			data:{'tpid':tpid,'tprice':tprice,'fkgc':fkgc,'subkilogramme':subkilogramme,'mtm':mtm},
			dataType:'json',
			success:function(data){
				if(data==1){
					$.messager.show({
						title:'我的消息',
						msg:'提交成功',
						timeout:2000,
						showType:'slide'
					});
					$('#win').window('close');
					$('#dg').datagrid('reload'); 
				}				
			}
		})
    });    
	 $('#btn2').bind('click', function(){    
		 $('#win').window('close');    
	    });  
	 
	 $('#cc').combobox({    
		    url:'CBBStation_cbbStation',    
		    valueField:'id',    
		    textField:'text'   
		});
	 $('#cc1').combobox({    
		    url:'CBBStation_cbbStation',    
		    valueField:'id',    
		    textField:'text'   
		});
	 
	 $('#btn4').bind('click', function(){    
		 $('#win1').window('close'); 
	    });    

	 $('#btn3').bind('click', function(){    
		var disid1=$('#cc').combo('getValue');
		var disid2=$('#cc1').combo('getValue');		
		$.ajax({
			url:'InsertStation_insertStation',
			type:'post',
			data:{'disid1':disid1,'disid2':disid2},
			dataType:'json',
			success:function(data){
				if(data==1){
					$.messager.show({
						title:'我的消息',
						msg:'添加成功',
						timeout:2000,
						showType:'slide'
					});
					$('#win1').window('close');
					$('#dg').datagrid('reload');
				}
			}
		})
	    });    


	
})
</script>
<body>
<table id="dg"></table> 

<div id="win" class="easyui-window" title="" style="width:600px;height:400px"   
        data-options="closed:true,modal:true">
        <div style="margin-left: 120px;margin-top: 50px"><div style="display:none">
站点编号<input id="tb1" class="easyui-textbox" type="text" style="width:300px"><br><br></div>
价格比例<input id="tb2" class="easyui-textbox" type="text" style="width:300px"><br><br>
首重费用<input id="tb3" class="easyui-textbox" type="text" style="width:300px"><br><br>
续重费用<input id="tb4" class="easyui-textbox" type="text" style="width:300px"><br><br>
转换比例<input id="tb5" class="easyui-textbox" type="text" style="width:300px"><br><br></div>
<div style="margin-left:200px;margin-top: 80px">
<a id="btn1" href="#" class="easyui-linkbutton">提交</a>
<a id="btn2" href="#" class="easyui-linkbutton">取消</a></div>
</div>

<div id="win1" class="easyui-window" title="" style="width:600px;height:400px"   
        data-options="closed:true,modal:true">
        <div style="margin-left:150px;margin-top: 80px">
 起/始站  <input id="cc" name="dept" value="" style="width:200px" data-options="editable:false"><br><br>     
  始/起站<input id="cc1" name="dept" value="" style="width:200px" data-options="editable:false"><br><br> </div>
   <div style="margin-left:220px;margin-top: 80px">
<a id="btn3" href="#" class="easyui-linkbutton">保存</a>
<a id="btn4" href="#" class="easyui-linkbutton">取消</a></div>
</div>    
</div>
</body>
</html>